package leetcode.weekly.week292;

// Solution1Test
public class Solution1 {

	public String largestGoodInteger(String num) {
		char[] cs = num.toCharArray();
		int max = -1;
		for (int i = 2; i < cs.length; i++) {
			if (cs[i] == cs[i - 1] && cs[i - 1] == cs[i - 2]) {
				int cur = (cs[i - 2] - '0') * 100 + (cs[i - 1] - '0') * 10 + (cs[i] - '0');
				if (cur > max) {
					max = cur;
				}
			}
		}
		return max == -1 ? "" : max == 0 ? "000" : String.valueOf(max);
	}

}
